﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Display.DialogUI {
    import flash.events.*;
    import Engine.Managers.*;
    import flash.display.*;
    import flash.geom.*;
    import flash.utils.*;
    import com.greensock.*;
    import Display.aswingui.*;
    import com.greensock.easing.*;

    public class NewsFlashDialog extends GenericDialog {

        protected static var m_NewsTitle:String = "";
        protected static var m_NewsSubhead:String = "";
        protected static var m_NewsMessage:String = "";

        protected var m_imageURL:String;
        protected var m_imageCount:int = 0;
        protected var m_itemObject:Object = null;
        protected var m_subhead:String = "";

        public function NewsFlashDialog(_arg1:String, _arg2:String="", _arg3:String="", _arg4:String="", _arg5:int=0, _arg6:Function=null, _arg7:Boolean=true, _arg8:int=0){
            this.m_subhead = _arg3;
            this.m_imageURL = _arg4;
            var _local9:int = GenericDialogView.TYPE_SHARECANCEL;
            super(_arg1, _arg2, _local9, _arg6, _arg2, "", _arg7);
            m_NewsTitle = _arg2;
            m_NewsSubhead = this.m_subhead;
            m_NewsMessage = _arg1;
        }
        public static function GetLastNewsTitle():String{
            return (m_NewsTitle);
        }
        public static function GetLastNewsSubhead():String{
            return (m_NewsSubhead);
        }
        public static function GetLastNewsMessage():String{
            return (m_NewsMessage);
        }

        override protected function loadAssets():void{
            this.m_itemObject = new Object();
            var _local1:String = Global.getAssetURL(this.m_imageURL);
            this.m_itemObject.image = LoadingManager.load(_local1, this.onAssetsLoaded);
            var _local2:String = Global.getAssetURL("assets/newsFlash/newspaper_bg.png");
            this.m_itemObject.bg = LoadingManager.load(_local2, this.onAssetsLoaded);
        }
        override protected function onAssetsLoaded(_arg1:Event=null):void{
            if (++this.m_imageCount < 2){
                return;
            };
            var _local2:Dictionary = new Dictionary(true);
            _local2["bg"] = (this.m_itemObject.bg.content as Bitmap);
            _local2["imageURL"] = (this.m_itemObject.image.content as Bitmap);
            m_jpanel = new NewsFlashDialogView(_local2, m_message, m_title, this.m_subhead, m_type, m_callback);
            this.finalizeAndShow();
        }
        override protected function finalizeAndShow():void{
            ASwingHelper.prepare(m_jpanel);
            m_jwindow.setContentPane(m_jpanel);
            ASwingHelper.prepare(m_jwindow);
            var _local1:int = m_jwindow.getWidth();
            var _local2:int = m_jwindow.getHeight();
            m_jwindow.setX((-(_local1) / 2));
            m_jwindow.setY((-(_local2) / 2));
            m_jwindow.show();
            m_holder.width = _local1;
            m_holder.height = _local2;
            setupDialogStatsTracking();
            onDialogInitialized();
        }
        override public function getDialogOffset():Point{
            return (new Point((m_jwindow.getWidth() / 2), (m_jwindow.getHeight() / 2)));
        }
        override protected function hideTween(_arg1:Function):void{
            var matParams:* = null;
            var startSize:* = null;
            var callback:* = _arg1;
            this.mouseEnabled = (this.mouseChildren = false);
            if (m_content == null){
                if (callback != null){
                    callback();
                };
            } else {
                matParams = {scale:1};
                startSize = new Point(0, 0);
                TweenLite.to(matParams, TWEEN_TIME, {
                    scale:0,
                    ease:Back.easeIn,
                    onUpdate:function ():void{
                        var _local1:* = new Matrix();
                        _local1.translate((-(startSize.x) / 2), (-(startSize.y) / 2));
                        _local1.scale(matParams.scale, matParams.scale);
                        _local1.translate((startSize.x / 2), (startSize.y / 2));
                        m_content.transform.matrix = _local1;
                    },
                    onComplete:callback
                });
            };
        }
        override protected function showTween():void{
            this.mouseEnabled = false;
            this.mouseChildren = false;
            if (m_centered){
                centerPopup();
            };
            var _local1:Point = new Point(m_content.width, m_content.height);
            var _local2:Matrix = new Matrix();
            _local2.scale(0.25, 0.25);
            m_content.transform.matrix = _local2;
            m_content.alpha = 0;
            TweenLite.to(m_content, 0.5, {
                alpha:1,
                scaleX:1,
                scaleY:1,
                rotation:720,
                onComplete:onShowComplete
            });
        }

    }
}//package Display.DialogUI 
